package gameEngine.agents.distrebution;

import java.util.Random;

import org.apache.log4j.Logger;
import org.w3c.dom.Document;
import org.w3c.dom.Element;

import Data.ConfigurationParameters;

public class Exponential implements Distribution{

	Logger log = Logger.getLogger(this.getClass());
	
	//Data members
    private double 	lambda = 1.0;
    private double 	F0 = 0;
    private double 	F1 = 0;
    private double 	intervalOfNormalization = 1;
    private Random 	random = new Random();
    
    
	/**
	 * 	Constructor
	 * 	@param lambda - parameter of exponential distribution
	 * @throws Exception 
	 */ 
	public Exponential(double lambda) {
        if (lambda <= 0){
            log.error("lambda should be greater than zero, lambda set to 1");
        }else{
        	this.lambda = lambda;
        }
	}
	

	/**
	* @return the mean of the Exponential distribution
	*/
	public double getMean() {
		 return 1 / lambda;
	}
	
	/**
	* @return the Variance of the Exponential distribution
	*/
	public double getVariance() {
		return 1 / (lambda * lambda); 
	}
	
	
	/**
	 * @return a random value from the Exponential distribution
	 */
	public double generateValue() {
        return lambda = 10 * random.nextDouble();
	}
	
	public Exponential clone(){
		return new Exponential(lambda);
	}
}
